package com.dfbz.demo;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

/**
 * @author lscl
 * @version 1.0
 * @intro:
 */
public class Demo01_迭代器的使用 {
    public static void main(String[] args) {
        Collection cities = new ArrayList();
        cities.add("清远");
        cities.add("韶关");
        cities.add("梅州");
        cities.add("湛江");

        // 获取这个集合的迭代器
        Iterator iterator = cities.iterator();

        while (iterator.hasNext()) {
            Object obj = iterator.next();
            System.out.println(obj);
        }
    }
}
